package com.ty.controller;

import com.ty.entity.Shelf;
import com.ty.entity.ShelfQuery;
import com.ty.entity.Warehouse;
import com.ty.entity.WarehouseQuery;
import com.ty.service.ShelfService;
import com.ty.service.WarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
//restfullApi
@RequestMapping("/api/shelf")
//@CrossOrigin(origins = "*") // 解决跨域问题
//@NoWapperX
public class ShelfController {

    @Autowired //自动注入
    private ShelfService shelfService;


    @GetMapping
    public List<Shelf> select(ShelfQuery query) {

        return shelfService.select(query);
    }

    @GetMapping("/tree")
    public List<Map> selectTree() {

        return shelfService.selectTree();
    }

    @PutMapping
    public int update(@RequestBody Shelf  shelf) {
        return shelfService.update(shelf);

    }
    @PostMapping
    public int insert(@RequestBody Shelf  shelf) {
        return shelfService.insert(shelf);

    }
    @DeleteMapping
    public int delete(Integer id) {
        return shelfService.delete(id);

    }
}